from enum import Enum


class User:
    @property
    def auth_type(self):
        raise NotImplementedError()

    @staticmethod
    def create_user(auth=None, **params):
        if auth:
            assert hasattr(AuthType, auth), "not support auth type"
            cls = getattr(AuthType, auth).value
        elif "password" in params:
            cls = AuthType.password.value
        else:
            raise Exception()
        return cls(**params)

    def get_auth_params(self):
        raise NotImplementedError()


class PasswordUser(User):
    def __init__(self, username, password, **kwargs) -> None:
        self.username = username
        self.password = password

    @property
    def auth_type(self):
        return AuthType.password.name

    def get_auth_params(self):
        return {"username": self.username, "password": self.password}


class KeyUser(User):
    def __init__(self, username, keyfile):
        self.username = username
        self.keyfile = keyfile
    
    @property
    def auth_type(self):
        return AuthType.key.name
    
    def get_auth_params(self):
        return {"username": self.username, "key_filename": self.keyfile}


class AuthType(Enum):
    password = PasswordUser
    key = KeyUser
